package com.example.bootdemo.common.log;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("api/logging")
public class LogTemplate{

    /*private final static Logger logger
            = LoggerFactory.getLogger(LogTemplate.class);*/

    @GetMapping("/test")
    public String test(){
        Object o = new Object();
        log.info("这是日志框架的输出信息{}"+o);
        log.debug("The entry is {}" + o);
//        Exception e = new Exception();
        //注意error方法想要打印完整的堆栈信息，需要如下，是因为error重载的方法限制
//        log.error("程序异常, 详细信息:{}", e.getLocalizedMessage() , e);
        return "测试成功";
    }

}